package com.woniu.mealsService.consumer;

import com.woniu.mealsService.service.OrderProductService;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author jiang
 */
@Component
public class OrderCloseConsumer {
    @Autowired
    private OrderProductService orderProductService;
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "delay_close_order"),
            exchange = @Exchange(name = "delay_Update_alipayclose"),
            key = "close"
    ))
    @RabbitHandler
    public void closeOrder(String orderId) throws Exception {
        try {
            orderProductService.closeOrder(orderId);
        }catch (Exception e){
            throw e;
        }
    }
}
